// 展示用户信息
import { useDataSource } from "./useDataSource"
import axios from "axios"
const getServeSource = resourceUrl => async ()=>{
    const response = await axios.get(resourceUrl)
    return response.data;
}

export const UserInfo = ({userId})=>{
    const user = useDataSource(getServeSource(`/user/${userId}`))
    const {name,age,hair} = user || {};
    return (
        user ? (
            <ul>
                <li>name:{name}</li>
                <li>age:{age}</li>
                <li>hair:{hair}</li>
            </ul>
        ):<p>loading</p>
    )
}